package cn.goktech.controller;

import cn.goktech.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
public class RespController {

    @RequestMapping("resp1")
    @ResponseBody
    public void resp(HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("hello你好");
    }

    @RequestMapping("resp2")
    @ResponseBody
    public String resp2() throws IOException {
        return "hellon你好";
    }
    @RequestMapping("resp3")
    @ResponseBody
    public User resp3()  {

        User user = new User(1,"admin","宜宾");
        return user;
    }
    @RequestMapping("resp4")
    @ResponseBody
    public List<User> resp4()  {
        List<User> list = new ArrayList<User>();
        User user1 = new User(1,"admin","宜宾");
        User user2 = new User(2,"admin2","宜宾3");
        User user3 = new User(3,"admin2","宜宾3");
        list.add(user1);
        list.add(user2);
        list.add(user3);
        return list;
    }
}
